package com.litong.litongjiaoyu.service.impl;

import com.litong.litongjiaoyu.dao.CampusDao;
import com.litong.litongjiaoyu.entity.SysCampus;
import com.litong.litongjiaoyu.service.CampusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName CampusServiceImpl
 * @Description 校区管理服务层具体实现
 * @Author jingz
 * @Date 2020/1/17 16:54
 * @Version 1.0
 **/
@Service
public class CampusServiceImpl implements CampusService {


    @Autowired
    private CampusDao campusDao;

    /**
     * 获取全部校区数据
     *
     * @return
     */
    @Override
    public List<SysCampus> query() {

        return campusDao.query();
    }

    /**
     * 根据id获取该校区数据
     *
     * @param id
     * @return
     */
    @Override
    public SysCampus getCampus(long id) {

        return campusDao.getCampus(id);
    }

    /**
     * 获取校区名称
     *
     * @return
     */
    @Override
    public List<String> getCampusName() {
        return campusDao.getCampusName();
    }

    /**
     * 添加校区
     *
     * @param campus
     * @return
     */
    @Transactional
    @Override
    public int insetCampus(SysCampus campus) {
        return campusDao.insetCampus(campus);
    }

    /**
     * 更新指定校区内容
     *
     * @param campus
     * @return
     */
    @Transactional
    @Override
    public int update(SysCampus campus) {

        return campusDao.update(campus);
    }

    /**
     * 删除指定校区
     *
     * @param id
     * @return
     */
    @Transactional
    @Override
    public int delete(long id) {
        return campusDao.delete(id);
    }

    /**
     * 删除全部校区
     *
     * @return
     */
    @Transactional
    @Override
    public int deleteAll() {
        return campusDao.deleteAll();
    }
}
